Add translations to times and numbers - #1223
Conversation
| @@ -0,0 +1,16 @@ | |||
| import { intlFormatDistance } from "date-fns"; | |||
|
|
|||
| const localeMap = { | |||
There was a problem hiding this comment.
I'm lacking a bit of context here, but are we redefining this list, rather than using a shared source of truth?
There was a problem hiding this comment.
I think the answer is that this map is for ensuring that our locales match up with the ones from the library
There was a problem hiding this comment.
could we move this into a central location, maybe a separate util called localeMappings.js or something, and make sure nowhere else is redefining it?
| }; | ||
|
|
||
| export const formatRelativeTime = (lastSavedTime, now, languageCode) => { | ||
| const locale = localeMap[languageCode] || localeMap.en; // Default to English if no match found; |
There was a problem hiding this comment.
shouldn't this fallback logic be handled by react-i18next, is this duplicated logic?
There was a problem hiding this comment.
hmmm possibly - my preference would be if we can default to the i18n default where possible to avoid setting this in multiple places. But perhaps we need a fallback even then to avoid weird breakages if that was ever to change (it's purposely different in the tests for instance)
There was a problem hiding this comment.
I get it's probably unlikely but it just feels a bit wrong to me that if the fallback language was changed across the app, this would still be falling back to en - at the very least we should be using a shared var for the fallback, that's also being used by react-i18next
### Added - Ability to translate demo project instructions (#1230) - Translations (#1212) ### Changed - Improved status bar styling (#1221) - Added method to translate last saved time (#1223) - Deleting unused strings and components (#1225) - Determine locale from web component attribute instead of browser path (#1244) ### Fixed - CrowdIn issue for pluralised strings with no `one` version (#1234) - Update `imagePanel.gallery` string to remove Title Casing for consistency (#1238) - Update `imageUploadButton.uploadImage` string to remove Title Casing for consistency (#1238) - Fixed typo in the `en.json` translation file (#1241) ### Removed - Remove unused translation string `filePanel.images` (#1238)
Editor-UI part of https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/588